package com.lvkerry.orderfood.controller

import com.lvkerry.orderfood.api.ApiBean
import com.lvkerry.orderfood.entity.MenuEntity
import com.lvkerry.orderfood.service.MenuService

import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody


@Controller
@RequestMapping("/menu")
class MenuController(private val menuService: MenuService) {


    @ResponseBody
    @PostMapping("/addDishMenu")
    fun addDishMenu(menuEntity: MenuEntity): ApiBean {
        return menuService.addMenu(menuEntity)
    }

    @ResponseBody
    @PostMapping("/deleteDishMenu")
    fun deleteDishMenu(id: Long): ApiBean {
        return menuService.deleteMenuById(id)
    }


    @ResponseBody
    @PostMapping("/findAllMenu")
    fun findAllMenu(): ApiBean {
        return menuService.findAllMenu()
    }


    @ResponseBody
    @PostMapping("/updateMenu")
    fun updateMenu(menuEntity: MenuEntity): ApiBean {
        return menuService.updateMenu(menuEntity)
    }

    @ResponseBody
    @PostMapping("/findMenuDetail")
    fun findMenuDetail(id: Long): ApiBean {

        return menuService.findMenuDetail(id)

    }


}